﻿@using OBUCare.Web.Models;
@using OBUCare.Core;
@using OBUCare.Core.Models;
@using OBUCare.Web.Infrastructure;
@model TransactionLogViewModel
@{
    Layout = "";
    ViewBag.Title = "流水单打印(收取押金)";
    var fundInfos = ViewBag.FundInfos as IList<FUND_INFO>;
    if (fundInfos == null)
    {
        fundInfos = new List<FUND_INFO>();
    }
}
<div>
    <p>
        <input type="button" onclick="printpage('divPrint')" value="打印" />
        <input type="button" onclick="CloseWindow()" value="关闭" />
    </p>
</div>
<div id="divPrint" style="width: 200%;">
    <table style="font-size: font-size: 14px;">
        <tr>
            <td colspan="8" style="text-align: center; font-size: 24px;">
                流水单
            </td>
        </tr>
        <tr style="height: 20px">
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr style="height: 10px; text-align: center; font-size: 14px;">
            <td style="text-align: right">
                营业厅：
            </td>
            <td style="text-align: left">
                @Model.AgentName
            </td>
            <td style="text-align: right">
                交易日期：
            </td>
            <td style="text-align: left">
                @Model.CREATED_DATE.ToString(UIConstants.DateFormatString)
            </td>
            <td style="text-align: right">
                流水编号：
            </td>
            <td colspan="2" style="text-align: left">
                @Model.SERIAL_NO
            </td>
        </tr>
        <tr style="height: 10px; text-align: center; font-size: 14px;">
            <td style="text-align: right">
                客户名称：
            </td>
            <td colspan="3" style="text-align: left">
                @Model.User_name
            </td>
            <td style="text-align: right">
                客户编号：
            </td>
            <td style="text-align: left">
                @Model.USER_NO
            </td>
        </tr>
        <tr style="height: 10px; text-align: center; font-size: 14px;">
            <td style="text-align: right">
                标签号：
            </td>
            <td style="text-align: left">
                @Model.OBU_NO
            </td>
            <td colspan="2">
            </td>
            <td style="text-align: right">
                维修单号：
            </td>
            <td colspan="2" style="text-align: left">
                @ViewBag.RepairOrderNo
            </td>
        </tr>
        <tr style="height: 10px; text-align: center; font-size: 14px;">
            <td style="text-align: right">
                收取押金：
            </td>
            <td style="text-align: left">
                @ViewBag.RepairPrice (元)
            </td>
            <td colspan="2">
            </td>
            <td style="text-align: right">
                打印次数：
            </td>
            <td style="text-align: left">
                @ViewBag.PrintCount
            </td>
        </tr>
        <tr style="height: 10px; text-align: center;font-size: 14px">
            <td>
                @if (fundInfos.FirstOrDefault(f => f.FUND_FROM == 0) != null)
                {
                    @:现金(元)
                                                                                                                                                                                                                                                                                                                                }
            </td>
            <td>
                @if (fundInfos.FirstOrDefault(f => f.FUND_FROM == 1) != null)
                {
                    @:支票(元)
                                                                                                                                                                                                                                                                                                                                }
            </td>
            <td>
                @if (fundInfos.FirstOrDefault(f => f.FUND_FROM == 2) != null)
                {
                    @:转账(元)
                                                                                                                                                                                                                                                                                                                                }
            </td>
            <td>
                @if (fundInfos.FirstOrDefault(f => f.FUND_FROM == 3) != null)
                {
                    @:POS机(元)
                                                                                                                                                                                                                                                                                                                                }
            </td>
            <td>
                @if (fundInfos.FirstOrDefault(f => f.FUND_FROM == 4) != null)
                {
                    @:应收(元)
                                                                                                                                                                                                                                                                                                                                }
            </td>
            <td>
                @if (fundInfos.FirstOrDefault(f => f.FUND_FROM == 5) != null)
                {
                    @:其他(元)
                                                                                                                                                                                                                                                                                                                                }
            </td>
            <td>
                合计(元)
            </td>
        </tr>
        <tr style="height: 10px; text-align: center; font-size: 14px">
            <td>
                @printFundInfoAmount(fundInfos, 0)
            </td>
            <td>
                @printFundInfoAmount(fundInfos, 1)
            </td>
            <td>
                @printFundInfoAmount(fundInfos, 2)
            </td>
            <td>
                @printFundInfoAmount(fundInfos, 3)
            </td>
            <td>
                @printFundInfoAmount(fundInfos, 4)
            </td>
            <td>
                @printFundInfoAmount(fundInfos, 5)
            </td>
            <td>
                @fundInfos.Sum(f => f.AMOUNT)
            </td>
        </tr>
        <tr style="height: 3px">
            <td colspan="8">
                &nbsp;
            </td>
        </tr>
        <tr style="height: 10px; text-align: center; font-size: 14px">
            <td style="text-align: right">
                打印时间：
            </td>
            <td style="text-align: left">
                @DateTime.Now.ToString(UIConstants.DateFormatString)
            </td>
            <td style="text-align: right">
                操作员：
            </td>
            <td style="text-align: left">
                @Model.OperatorName   &nbsp; &nbsp; &nbsp;
            </td>
            <td style="text-align: right">
                客户签字：
            </td>
        </tr>
    </table>
</div>
@Scripts.Render("~/bundles/Common")
@helper printFundInfoAmount(IList<FUND_INFO> fundInfos, int fundFrom)
    {
        var info = fundInfos.FirstOrDefault(f => f.FUND_FROM == fundFrom);
        if (info != null)
        {    
    @info.AMOUNT 
        }
}